//
//  MoneyTableViewCell.m
//  忘不了
//
//  Created by rimi on 16/7/10.
//  Copyright © 2016年 handuan. All rights reserved.
//

#import "MoneyTableViewCell.h"
#import "UIColor+Expand.h"
#import "SDAutoLayout.h"

@implementation MoneyTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self loadUI];
    }
    return self;
}

- (void)loadUI {
    _backGroundView = [[UIView alloc]init];
    _moneyLabel = [[UILabel alloc]init];
    _titleLabel = [[UILabel alloc]init];
}

- (void)loadUIwithData:(NSDictionary *)data
{
    self.backgroundColor = [UIColor clearColor];
    
    if (_money > 0 && _money < 50) {
        _index = self.contentView.width*0.1;
    }
    if (_money >= 50 && _money < 200) {
        _index = self.contentView.width*0.15;
    }
    if (_money >= 200 && _money < 500) {
        _index = self.contentView.width*0.2;
    }
    if (_money >= 500 && _money < 1000) {
        _index = self.contentView.width*0.25;
    }
    if (_money >= 1000 && _money < 2000) {
        _index = self.contentView.width*0.3;
    }
    if (_money > 2000 && _money < 5000) {
        _index = self.contentView.width*0.35;
    }
    if (_money >= 5000) {
        _index = self.contentView.width*0.4;
    }
    
    _backGroundView.backgroundColor = [UIColor specialRandomColor];
    [self.contentView addSubview:_backGroundView];
    _backGroundView.sd_layout
    .leftSpaceToView(self.contentView,0)
    .topSpaceToView(self.contentView,0)
    .heightRatioToView(self.contentView,1)
    .widthIs(_index+20);
    
    _moneyLabel.text = data[@"money"];
    _moneyLabel.textColor = [UIColor whiteColor];
    _moneyLabel.font = [UIFont systemFontOfSize:20];
    _moneyLabel.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:_moneyLabel];
    _moneyLabel.sd_layout
    .leftSpaceToView(self.contentView,10)
    .heightRatioToView(self.contentView,1)
    .topSpaceToView(self.contentView,0)
    .widthIs(_index);
    
    _titleLabel.text = data[@"title"];
    _titleLabel.textColor = [UIColor darkGrayColor];
    _titleLabel.font = [UIFont systemFontOfSize:20];
    _titleLabel.textAlignment = NSTextAlignmentLeft;
    _titleLabel.numberOfLines = 0;
    [self.contentView addSubview:_titleLabel];
    _titleLabel.sd_layout
    .leftSpaceToView(_backGroundView,10)
    .topSpaceToView(self.contentView,0)
    .bottomSpaceToView(self.contentView,0)
    .rightSpaceToView(self.contentView,10);
    
}



@end
